from typing import Optional
import typing
import PySide6.QtCore
import PySide6.QtWidgets
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QWidget

from ..SmallFormBase import SmallFromBase
from .Ui_DigitalDisplay import Ui_DigitalDisplay


class DigitalDisplay(SmallFromBase):
    def __init__(
        self, 
        parent: Optional[PySide6.QtWidgets.QWidget] = None, 
        f: PySide6.QtCore.Qt.WindowFlags = Qt.Widget) -> None:
        ###########################################
        super().__init__(parent=parent, f=f)
        self._ui = Ui_DigitalDisplay()
        self._ui.setupUi(self)

    def SetValue(self, value: typing.Any) -> None:
        '''
        function:
            设置数值
        '''
        # return super().SetValue(value)
        if (isinstance(value, float)):
            self._ui.lcdNumber.display(value)
    
    def UpdateProperty(self, value: 'dict') -> None:
        # return super().UpdateProperty(value)
        name_ = value.get('name', None)
        if (isinstance(name_, str)):
            self._ui.label.setText(name_)